<include file="Public/header" /> 

<!--主窗体-->
<div class="container app">
	<!--左侧菜单-->
	<include file="Public/sidebar" /> 
	<!--左侧菜单//-->
	
	<!-- mainCon -->
	<div id="mainCon" class="mainCon">
		<h4>视频素材</h4>
		<form class="form-horizontal" id="myform">
			
			<div class="form-group">
				<label for="createtime" class="col-sm-2 control-label">标题</label>
				<div class="col-sm-5">
					<input type="text" class="form-control" name="title" value="<{$result['title']}>" placeholder="标题">
				</div>
			</div>
			
			<div class="form-group">
				<label for="weixin" class="col-sm-2 control-label">上传时间</label>
				<div class="col-sm-5">
					<p class="form-control-static text-info">
						<{$result['createtime']|date='Y-m-d H:i:s',###}>
					</p>
				</div>
			</div>
			
			<div class="form-group">
				<label for="cid" class="col-sm-2 control-label">所属分类</label>
				<div class="col-sm-5">
					<select class="form-control" name="cid">
						<option value="0">-请选择分类-</option>
						<foreach name="cate" item="vo">
							<option value="<{$vo['id']}>" <if condition="$result['cid'] eq $vo['id']">selected</if>><{$vo['name']}></option>
						</foreach>
					</select>
				</div>
			</div>
			
			<!-- 图文预览 -->			
			<div class="form-group">
				<label for="" class="col-sm-2 control-label">视频封面</label>
				<div class="col-sm-5">
					<div class="upload-file-box" style="width:350px">
						<div class="radio col-sm-5">
							<a class="btn btn-default" id="uploadify">上传产品图片</a> <span style="margin-top:10px;float:left;color:#999">（仅允许上传1MB以内的图片）</span>
						</div>
						<div id="upload-file-view" class="OneImageBox upload-view">
							<div id="showimg">
								<if condition="!empty($result['video_picture'])">
									<div style="width:100px;height:100px;border:1px solid #ccc;overflow:hidden;float:left;">
										<img src="/<{$result['video_picture']}>" style="width:100px;height:100px;float:left;margin:0 auto;padding:5px;">
										<div onclick="removeImg(this);" style="height:30px;width:100%;background:#000;opacity:.6;text-align:center;z-index:3;position:relative;bottom:30px;color:#fff;line-height:30px;float:left;cursor:pointer;">删除</div>
									</div>
									<input type="hidden" class="img_input" name="thumb" value="<{$result['video_picture']}>">
								</if>
							</div>
	
						</div>
					</div>
				</div>
			</div>
			
			
			<iframe height="480" width="400" src="<{$result['upload_link']}>" frameborder="0" allowfullscreen="" style="width: 100%; height: 300px;"></iframe>
				
			<div style="clear:both;"></div>
			<div class="form-group" style="margin-top: 25px;">
				<div class="col-sm-offset-2 col-sm-10">
					<button class="btn btn-default col-sm-2 delAct" data-id="<{$result['id']}>" data-type="1">修改</button>
				</div>
			</div>
		</form>
		
	</div>
	<!-- mainCon// -->
	
</div>
<!--主窗体//-->

<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/validate/messages_zh.js"></script>
<script src="__PUBLIC__/js/uploadify/jquery.uploadify.min.js"></script>
<script>
$(function(){
	
	$(".delAct").click(function(){
		var that = this;
		var cid  = $('select[name="cid"]').val();
		var title = $('input[name="title"]').val();
		var itemid = $(that).attr("data-id");
		var thumb  = $('input[name="thumb"]').val();
		
		
		layer.confirm('确认修改', {icon: 3, title:'提示'}, function(index){	
			$.post("<{:U('do_video_edit')}>",{id:itemid,cid:cid,title:title,thumb:thumb},function(r){
				if(r.status != 1){
					layer.close(index);
					layer.alert(r.info,{icon: 2});
				}else{
					window.location.href = "<{:U('Admin/Material/video_list',array('k'=>10,'sk'=>5))}>";
				}
			});
		});
		return false;
	});
	

	// 文件上传
	$("#uploadify").uploadify({
		'swf'           : '/Public/js/uploadify/uploadify.swf',
		'uploader'      : "<?php echo U('Admin/Gallery/uploadImg');?>",
		'fileTypeExts'	: '*.jpg;*.png;*.gif',
		'width'			: 90,
		'buttonText' : '<a class="btn btn-default" id="uploadify">上传图片</a>',
		'hideButton' : true,
		'multi': false,
		'fileObjName' : 'imgFile',
		'fileSizeLimit' : '1MB',
		'multi'    : false, //开启,多选文件
		'uploadLimit' : 1, //允许上传文件个数
		'onUploadError' : function(back) {
			
		},
		'onUploadStart' : function(file) {

		},
		'onUploadSuccess' : function(file,data,response) {
			var r = jQuery.parseJSON(data);
			if(r.error == 0){
				$('#showimg').html('');
				var htm = '<div style="width:100px;height:100px;border:1px solid #ccc;overflow:hidden;float:left;margin-bottom:10px;">';
				htm += '<img src="/'+r.imgUrl+'" style="width:100px;height:100px;float:left;margin:0 auto;padding:5px;">';
				htm += '<div onclick="removeImg(this);" style="height:30px;width:100%;background:#000;opacity:.6;text-align:center;z-index:3;position:relative;bottom:30px;color:#fff;line-height:30px;float:left;cursor:pointer;">删除</div>';
				htm += '<input type="hidden" class="img_input" name="thumb" value="'+r.imgUrl+'"/>';
				htm += '</div>';
				$("#showimg").append(htm);
			}
		},

	});	
		
});
	
		//移除图片
	function removeImg(obj){
		$(obj).parent().remove();
	}

	

</script>

<include file="Public/footer" /> 